package com.example.redstarcommerce.cn.dh.shopcart.controller;

import com.example.redstarcommerce.cn.dh.common.vo.Result;
import com.example.redstarcommerce.cn.dh.shopcart.pojo.ShopCart;
import com.example.redstarcommerce.cn.dh.shopcart.service.impl.ShopCartServiceImpl;
import com.sun.istack.internal.NotNull;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.util.List;

/**
 * @ClassName ShopController
 * @Author AndyWu
 * @Date 2024-11-01 22:37
 * @Motto 学不死就往死里学
 * @Version 1.0
 */


@RestController
@RequestMapping("/shopcart")
@Api(tags = "购物车接口",description = "购物车")
@Slf4j
public class ShopCartController {
    @Autowired
    private ShopCartServiceImpl shopCartService;



@RequestMapping("/getall")
@ApiOperation(value = "查询所有商品", notes = "getAll", httpMethod = "GET")
public Object getAll() {
    Result<List<ShopCart>> all = shopCartService.getAll();
    return all;
}

  @RequestMapping("/deleteShopCart")
  @ApiOperation(value = "删除商品",notes = "deleteShopCart",httpMethod = "POST")
    public Object deleteShopCart(String uid) {
      Result<Boolean> result = shopCartService.deleteShopCart(uid);
      return result;
  }

    @RequestMapping("/insertShopCart")
    @ApiOperation(value = "添加商品",notes = "insertShopCart",httpMethod = "POST")
    public Object insertShopCart(String name, String type, String introduce, Float price, String map) {
      Result<Boolean> result = shopCartService.insertShopCart(name, type, introduce, price, map);
      Result.success(result);
      return result;
    }


    @RequestMapping("/updateShopCart")
    @ApiOperation(value = "修改商品",notes = "updateShopCart",httpMethod = "POST")
    public Object updateShopCart(String uid,String name, String type, String introduce, Float price, String map) {
      Result<Boolean> result = shopCartService.updateShopCart(uid,name, type, introduce, price, map);
      return result;
    }



}
